﻿using System;

namespace CSharp基础1
{
	enum E_PlayerType
	{
		other,
		girl,
		boy
	}
	class Program
	{
		static void print(params int[] arr)
		{
			for (int i = 0; i < arr.Length; i++)
			{
				Console.Write(arr[i] + " ");
			}
			Console.WriteLine();
		}
		static void print2(int a, int b = 10, int c = 20)
		{
			Console.Write(a + " ");
			Console.Write(b + " ");
			Console.Write(c + " ");
		}
		static void print3(int a, int b)
		{
			Console.Write(a + " ");
			Console.Write(b + " ");
		}
		static void print3(ref int a, int b)
		{
			Console.Write(a + " ");
			Console.Write(b + " ");
		}
		static void print3(ref long a, int b)
		{
			Console.Write(a + " ");
			Console.Write(b + " ");
		}
		static void print3(int a, out int b)
		{
			b = 10;
			Console.Write(a + " ");
			Console.Write(b + " ");
		}
		static void BubbleSort(int[] nums, bool sortType)
		{
			bool order;
			// 冒泡排序
			for (int i = 0; i < nums.Length; i++)
			{
				bool flag = true;
				for (int j = 0; j < nums.Length - 1 - i; j++)
				{
					order = sortType ? nums[j] > nums[j + 1] : nums[j] < nums[j + 1];
					if (order)
					{
						flag = false;
						int temp = nums[j];
						nums[j] = nums[j + 1];
						nums[j + 1] = temp;
					}
					
				}
				if (flag) break;
			}
		}
		static void SelectSort(int[] nums, bool sortType)
		{
			bool order;
			for (int i = 0; i < nums.Length; i++)
			{
				int index = 0;
				for (int j = 1; j < nums.Length - i; j++)
				{
					order = sortType ? nums[j] > nums[index] : nums[j] < nums[index];
					if (order)
					{
						index = j;
					}
				}
				if (index != nums.Length - 1 - i)
				{
					int temp = nums[nums.Length - 1 - i];
					nums[nums.Length - 1 - i] = nums[index];
					nums[index] = temp;
				}
			}
		}
		static void Main(string[] args)
		{
			//把string转成枚举呢
			//Parse后第一个参数：你要转为的是哪个枚举类型第二个参数：用于转换的对应枚举项的字符串
			//转换完毕后是一个通用的类型我们需要用括号强转成我们想要的目标枚举类型
			E_PlayerType playerType = (E_PlayerType)Enum.Parse(typeof(E_PlayerType), "other");
			Console.WriteLine(playerType);

			//int[] a1 = new int[5];
			//int[] a2 = new int[5];
			//int[,] a3 = new int[2, 3];
			//int[,] a4 = new int[2, 3];

			//string s1 = "hello";
			//string s2 = s1;
			//s2 = "world";
			//s2 = s1;
			//print(1, 2, 3, 4, 5);
			//print(new int[] { 1, 2, 3, 4, 5});
			//print2(1);
			//print2(a:100, c:10);

			print3(1, 2);
			int a = 3;
			print3(ref a, 2);
			int b;
			print3(1, out b);
			int[] nums1 = new int[] { 1, 2, 5, 4, 3 };
			BubbleSort(nums1, true);
			print(nums1);
			int[] nums2 = new int[] { 1, 2, 5, 4, 3 };
			BubbleSort(nums2, false);
			print(nums2);

			int[] nums3 = new int[] { 1, 2, 5, 4, 3 };
			SelectSort(nums3, true);
			print(nums3);

			int[] nums4 = new int[] { 1, 2, 5, 4, 3 };
			SelectSort(nums4, false);
			print(nums4);
		}
	}
}

